# coding=utf-8
# encoding=utf-8

import json


class MyEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, bytes):
            return str(obj, encoding='utf-8');
        return json.JSONEncoder.default(self, obj)


class JsonSerializable(object):
    def toJson(self):
        return json.dumps(self.__dict__, cls=MyEncoder)

    def __repr__(self):
        return self.toJson()


class PictureJsonData(JsonSerializable):
    def __init__(self, datetime, image_base64, image_dir, file_type):
        self.datetime = datetime
        self.image_base64 = image_base64
        self.image_dir = image_dir
        self.file_type = file_type
